﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;

namespace MyCpuMonitor.Classes.WMI
{
    public class TemperatureProbe
    {
        #region global vars

        private readonly ManagementObjectSearcher _mos;
        private readonly ManagementObjectCollection _moc;


        public string Count { get; set; }
        #endregion

        #region Ctor

        public TemperatureProbe()
        {
            _mos = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
            _moc = _mos.Get();

            Count = _moc.Count.ToString();
        }

        #endregion

        public string Accuracy()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["Accuracy"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string Availability()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["Availability"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string Caption()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["Caption"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string ConfigManagerErrorCode()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["ConfigManagerErrorCode"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string ConfigManagerUserConfig()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["ConfigManagerUserConfig"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string CreationClassName()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["CreationClassName"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string CurrentReading()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["CurrentReading"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string Description()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["Description"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string DeviceID()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["DeviceID"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string ErrorCleared()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["ErrorCleared"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string ErrorDescription()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["ErrorDescription"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string InstallDate()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["InstallDate"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string IsLinear()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["IsLinear"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string LastErrorCode()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["LastErrorCode"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string LowerThresholdCritical()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["LowerThresholdCritical"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string LowerThresholdFatal()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["LowerThresholdFatal"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string LowerThresholdNonCritical()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["LowerThresholdNonCritical"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string MaxReadable()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["MaxReadable"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string MinReadable()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["MinReadable"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string Name()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["Name"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string NominalReading()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["NominalReading"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string NormalMax()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["NormalMax"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string NormalMin()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["NormalMin"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string PNPDeviceID()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["PNPDeviceID"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string PowerManagementCapabilities()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["PowerManagementCapabilities"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string PowerManagementSupported()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["PowerManagementSupported"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string Resolution()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["Resolution"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string Status()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["Status"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string StatusInfo()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["StatusInfo"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string SystemCreationClassName()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["SystemCreationClassName"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string SystemName()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["SystemName"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string Tolerance()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["Tolerance"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string UpperThresholdCritical()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["UpperThresholdCritical"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string UpperThresholdFatal()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["UpperThresholdFatal"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }

        public string UpperThresholdNonCritical()
        {
            var s = "";
            try
            {
                foreach (var o in _moc)
                    s = o["UpperThresholdNonCritical"].ToString().Trim();
            }
            catch
            {
                s = "Unable to Determine";
            }

            return s;
        }


    }
}